/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2014-2019.
 * Description: header for idump debug printk
 * Author: nixiaoming
 * Create: 2014-6-18
 */

#ifndef _LINUX_IDUMP_DEBUG_H_
#define _LINUX_IDUMP_DEBUG_H_

#ifdef CONFIG_RTOS_IDUMP
extern unsigned int idump_debug;

#if defined(CONFIG_RTOS_IDUMP_FORCE) || defined(CONFIG_RTOS_IDUMP_TRIGGER)
#define DEBUG_IDUMP_TRIGGER 1
#define DEBUG_IDUMP_FILTER 2
#define idump_dbg(leval, fmt, ...) do {if (idump_debug & leval) {printk(fmt, ##__VA_ARGS__); } } while (0)

#define idump_show_func(tsk) idump_dbg(DEBUG_IDUMP_TRIGGER, "[idump][current:%s %d][task:%s %d tgid:%d][func:%s]\n", \
		current->comm, current->pid, tsk->comm, tsk->pid, tsk->tgid, __func__)

#define idump_control_debug(tsk, fmt, ...) \
	idump_dbg(DEBUG_IDUMP_TRIGGER, "[idump][current:%s %d][task:%s %d tgid:%d][func:%s]" fmt, \
			current->comm, current->pid, tsk->comm, tsk->pid, tsk->tgid, __func__, ##__VA_ARGS__)
#endif

#define idump_filter_debug(fmt, ...) do { \
	if (idump_debug != 0) { \
		printk(fmt, ##__VA_ARGS__); \
	} \
} while (0)

#else
#if defined(CONFIG_RTOS_IDUMP_FORCE) || defined(CONFIG_RTOS_IDUMP_TRIGGER)
#define idump_dbg(leval, fmt, ...) do {} while (0)
#define idump_show_func(tsk) do {} while (0)
#define idump_control_debug(tsk, fmt, ...) do {} while (0)
#endif

#define idump_filter_debug(fmt, ...) do {} while (0)
#endif

#endif
